package com.boot6.service;

import com.boot6.mapper.DeptMapper01;
import com.boot6.mapper.EmpMapper;
import com.boot6.pojo.DeptVo01;
import com.boot6.pojo.Emp;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author wzm
 * @create 2024-03-04 11:55
 * project_name:JavaWeb2401
 * @Description
 */
public class EmpServiceImpl {
    @Autowired
    private DeptMapper01 deptMapper01;
    @Autowired
    private EmpMapper empMapper;

    //准备一个根据id查询部门的详细信息 且要查询部门中的员工返回给前端
    public DeptVo01 getDeptAndEmpById(Integer id){
        //调用根据id查询部门的方法
        DeptVo01 deptById = deptMapper01.getDept(id);//dept{id1 name技术部 } select * from dept where id = 2
        //拿着id去调用根据部门id查询部门中员工的集合
        List<Emp> emps = empMapper.selecctEmpByDeptId(deptById.getId());//select * from emp where dept_id = 2
        deptById.setEmps(emps);

        return deptById;

    }

}
